import json
# 我们的菜单成功了状态码就是1000
# 失败了就是1001
# 其他不确定就是1003
from django.http import HttpResponse, JsonResponse


class MenuResponse:

    @staticmethod
    def success(data):
        result = {"status": 1000, "data": data}
        return HttpResponse(json.dumps(result), content_type="application/json")

    @staticmethod
    def failed(data):
        result = {"status": 1001, "data": data}
        return HttpResponse(json.dumps(result), content_type="application/json")

    @staticmethod
    def other(data):
        result = {"status": 1002, "data": data}
        return HttpResponse(json.dumps(result), content_type="application/json")


# 商品的响应全部都是2开头的
class GoodsResponse:

    @staticmethod
    def success(data):
        result = {"status": 2000, "data": data}
        return JsonResponse(result, safe=False)

    @staticmethod
    def failed(data):
        result = {"status": 2001, "data": data}
        # return HttpResponse(json.dumps(result), content_type="application/json")
        return JsonResponse(result, safe=False)

    @staticmethod
    def other(data):
        result = {"status": 2002, "data": data}
        return HttpResponse(json.dumps(result), content_type="application/json")


class CartResponse:

    @staticmethod
    def success(data):
        result = {"status": 3000, "data": data}
        return JsonResponse(result, safe=False)

    @staticmethod
    def failed(data):
        result = {"status": 3001, "data": data}
        return JsonResponse(result, safe=False)

    @staticmethod
    def other(data):
        result = {"status": 3002, "data": data}
        return JsonResponse(result, safe=False)


class UserResponse:

    @staticmethod
    def success(data):
        result = {"status": 4000, "data": data}
        return JsonResponse(result, safe=False)

    @staticmethod
    def failed(data):
        result = {"status": 4001, "data": data}
        return JsonResponse(result, safe=False)

    @staticmethod
    def other(data):
        result = {"status": 4002, "data": data}
        return JsonResponse(result, safe=False)
